/*
 ----------------------------------------------------------------------------------
                           "THE BEER-WARE COPYRIGHT LICENSE"
                                     (Revision 43)
                                      -----------
    Rymek [rymek@rymek.org] wrote this file. As long as You retain this notice and
    this file has been sent directly to You by the author, You can do whatever You
    want with this stuff as long as You don't sell or rent it. If we meet some day,
    and You think this stuff is worth it, You can buy me a beer in return :-)
                                                                 __________
                                                                 Paweł Rymaszewski
  ----------------------------------------------------------------------------------
 */

package processing.objects;

/**
 * Class represents Server object. Class stores DB Server information required
 * to connect to a specific database server
 *
 * @author rymek
 *         User: rymek
 *         Date: 30.06.11
 *         Time: 10:10
 */
public class Server {

    private String url = "";        // server IP address/url
    private String port = "";       // server port number
    private String tnsName = "";    // server TNS name
    private String userName = "";   // user name
    private String userPass = "";   // password

    /**
     * Default constructor
     */
    public Server() {
    }

    /**
     * Copy constructor
     *
     * @param serverInfo object to create copy of
     */
    public Server(String serverInfo) {
        this.url = serverInfo.split(":")[0];
        this.port = serverInfo.split(":")[1];
        this.tnsName = serverInfo.split(":")[2];
        this.userName = serverInfo.split(":")[3];
        this.userPass = serverInfo.split(":")[4];
    }

    public Server(String url, String port, String tnsname) {
        this.url = url;
        this.port = port;
        this.tnsName = tnsname;
    }

    public String getConnectionUrl() {
        return "jdbc:oracle:thin:@" + this.url + ":" + this.port + ":"
                + this.tnsName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getTnsName() {
        return tnsName;
    }

    public void setTnsName(String tnsName) {
        this.tnsName = tnsName;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }

    @Override
    public String toString() {
        return "ServerInfoPanel{" +
                "url='" + url + '\'' +
                ", port='" + port + '\'' +
                ", tnsName='" + tnsName + '\'' +
                ", userName='" + userName + '\'' +
                ", userPass='" + userPass + '\'' +
                '}';
    }
}
